package com.dengyuanke.wx.controller;


import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.dengyuanke.common.result.JsonResult;
import com.dengyuanke.entity.Carousel;
import com.dengyuanke.service.ICarouselService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 轮播图 前端控制器
 * </p>
 *
 * @author dengyuanke
 * @since 2017-11-07
 */
@Api(tags = "轮播图相关API")
@RestController
public class CarouselController {

    @Autowired
    private ICarouselService carouselService;

    /**
     * 获得轮播图
     * @param type
     * @return
     */
    @ApiOperation(value="获得轮播图")
    @ApiParam(value="轮播图类型必传 1首页，2商品详情",name="type",required=true)
    public JsonResult getCarousel(int type){
        List<Carousel> carousels = carouselService.selectList(new EntityWrapper<Carousel>().eq("type", type));
        return JsonResult.renderSuccess(carousels);
    }
	
}
